﻿using ChatSample.Models;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ChatSample.Hubs
{
    public class ChatHub : Hub
    {
        public ChatHub()
        {
            var t= this.Context;
        }
        public async Task Send(string name, string message)
        {
            // Call the broadcastMessage method to update clients.

            //await Clients.Client(connectionId).SendAsync('broadcastMessage', name, message);
            Console.WriteLine(this.Context.ConnectionId);

            var friendId = ChatList.GetConnectionId("xl");
           
            //指定客户端发送 内容（接收内容方法，参数1，参数2）
            await Clients.Client(friendId).SendAsync("broadcastMessage", name, message); 

            
        }
    }
}